import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home.vue'

import adminHome from '@/views/admin/adminHome.vue'
import adminRole from '@/views/admin/adminRole.vue'
import adminBusiness from '@/views/admin/adminBusiness.vue'
import a_RoleRolelist from '@/views/admin/a_RoleRolelist.vue'
import a_RoleRoleadd from '@/views/admin/a_RoleRoleadd.vue'
import a_BusinessBusinesslist from '@/views/admin/a_BusinessBusinesslist.vue'

import businessHome from '@/views/business/businessHome.vue'
import businessOrder from '@/views/business/businessOrder.vue'
import businessShoppingMall from '@/views/business/businessShoppingMall.vue'
import businessMessage from '@/views/business/businessMessage.vue'
import b_OrderSuccess from '@/views/business/b_OrderSuccess.vue'
import b_OrderDefeat from '@/views/business/b_OrderDefeat.vue'
import b_OrderBarter from '@/views/business/b_OrderBarter.vue'
import b_ShoppingMallCate from '@/views/business/b_ShoppingMallCate.vue'
import b_ShoppingMallShoplist from '@/views/business/b_ShoppingMallShoplist.vue'

import Login from '@/views/Login.vue'
import userEnroll from '@/views/user/userEnroll.vue'
import userHome from '@/views/user/userHome.vue'
const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes: [
        {
            path: '/',
            redirect: '/login'
        },
        {
            path: '/login',
            name: 'Login',
            component: Login
        },
        {
            path: '/userEnroll',
            name: 'userEnroll',
            component: userEnroll
        },
        {
            path: '/userHome',
            name: 'userHome',
            component: userHome
        },
        {
            path: '/home',
            name: 'Home',
            component: Home,
            children: [
                //商户路由
                
                {
                    path: 'businessHome', // 修改为相对路径
                    name: 'businessHome',
                    component: businessHome
                },
                {
                    path: 'businessOrder', // 修改为相对路径
                    name: 'businessOrder',
                    component: businessOrder,
                    children: [
                        {
                            path: '',
                            redirect: 'b_OrderSuccess' // 修改为相对路径
                        },
                        {
                            path: 'b_OrderSuccess',
                            name: 'b_OrderSuccess',
                            component: b_OrderSuccess
                        },
                        {
                            path: 'b_OrderDefeat',
                            name: 'b_OrderDefeat',
                            component: b_OrderDefeat
                        },
                        {
                            path: 'b_OrderBarter',
                            name: 'b_OrderBarter',
                            component: b_OrderBarter
                        },
                    ]
                },
                {
                    path: 'businessShoppingMall', // 修改为相对路径
                    name: 'businessShoppingMall',
                    component: businessShoppingMall,
                    children: [
                        {
                            path: '',
                            redirect: 'b_ShoppingMallCate' // 修改为相对路径
                        },
                        {
                            path: 'b_ShoppingMallCate',
                            name: 'b_ShoppingMallCate',
                            component: b_ShoppingMallCate
                        },
                        {
                            path: 'b_ShoppingMallShoplist',
                            name: 'b_ShoppingMallShoplist',
                            component: b_ShoppingMallShoplist
                        },
                    ]
                },
                {
                    path: 'businessMessage', // 修改为相对路径
                    name: 'businessMessage',
                    component: businessMessage
                },
                // 管理员路由
                {
                    path: 'adminHome',
                    name: 'adminHome',
                    component: adminHome
                },
                {
                    path: 'adminRole',
                    name: 'adminRole',
                    component: adminRole,
                    children: [
                        {
                            path: '',
                            redirect: 'a_RoleRolelist' // 重定向到子路由
                        },
                        {
                            path: 'a_RoleRolelist',
                            name: 'a_RoleRolelist',
                            component: a_RoleRolelist
                        },
                        {
                            path: 'a_RoleRoleadd',
                            name: 'a_RoleRoleadd',
                            component: a_RoleRoleadd
                        }
                    ]
                },
                {
                    path: 'adminBusiness',
                    name: 'adminBusiness',
                    component: adminBusiness,
                    children: [
                        {
                            path: '',
                            redirect: 'a_BusinessBusinesslist' // 重定向到子路由
                        },
                        {
                            path: 'a_BusinessBusinesslist',
                            name: 'a_BusinessBusinesslist',
                            component: a_BusinessBusinesslist
                        }
                    ]
                },
            ]
        },



    ]
})

export default router
